package com.qd.panda.dc.dto.charge;

import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import lombok.ToString;
import lombok.experimental.Accessors;

/**
 * 启动充电返回值
 *
 * @author sjk
 */

@Data
@Accessors(chain = true)
@ToString
public class StartChargeRespDTO {
    /**
     * 充电单号
     */
    @JsonProperty("StartChargeSeq")
    private String startChargeSeq;
    /**
     * 充电订单状态：1：启动中2：充电中3：停止中4：已结束5：未知
     */
    @JsonProperty("StartChargeSeqStat")
    private Integer startChargeSeqStat;
    /**
     * 充电设备接口编码
     */
    @JsonProperty("ConnectorID")
    private String connectorID;
    /**
     * 0:成功；1:失败
     */
    @JsonProperty("SuccStat")
    private Integer succStat;
    /**
     * 0:无；1:此设备不存在；2:此设备离线：3～99:自定义
     */
    @JsonProperty("FailReason")
    private Integer failReason;

    public boolean isSuccess() {
        return null != succStat && succStat.equals(0);
    }

    public String failReasonMsg() {
        String failReasonMsg = "未知错误";
        if (null != failReason) {
            switch (failReason) {
                case 0:
                    failReasonMsg = "无";
                    break;
                case 1:
                    failReasonMsg = "此设备不存在";
                    break;
                case 2:
                    failReasonMsg = "此设备离线";
                    break;
                default:
                    break;
            }
        }
        return failReasonMsg;
    }

    public void freeData() {
        this.startChargeSeq = null;
        this.startChargeSeqStat = null;
        this.connectorID = null;
        this.succStat = null;
        this.failReason = null;
    }
}